#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define DEGREE 512
#define BLOCKD 8
#define BLOCK_CNT ((DEGREE * DEGREE) / (BLOCKD * BLOCKD))

#define ZEO 0xfe
#define ONE 0x01

typedef unsigned char UCHAR;

int getCipher(int tag);

void getBlockZIndex(UCHAR raw[DEGREE][DEGREE], int sx, int sy, UCHAR pixel[]);
void getBlockRelevacne(UCHAR pixel[]);
void getRelevance(UCHAR raw[DEGREE][DEGREE], int relv[]);

void randomCipherWrite(UCHAR raw[DEGREE][DEGREE], int rate);

void pos_reverse(UCHAR pos_raw[DEGREE][DEGREE]);
void neg_reverse(UCHAR neg_raw[DEGREE][DEGREE]);

double getRm(int raw_relv[], int mod_relv[]);

void writeImage(FILE *carry, UCHAR header[], UCHAR mod[DEGREE][DEGREE]);

void readHeader(FILE *image, UCHAR header[]);
void readImage(FILE *image, UCHAR raw[DEGREE][DEGREE]);